﻿<UserControl x:Class="SoftSource.Timecard.Views.ProjectMemberEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:softsourceConverters="clr-namespace:SoftSource.Common.Converters;assembly=SoftSource.Common.Silverlight"
             xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
             xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:dataFormToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d">

    <UserControl.Resources>
        <softsourceConverters:MoneyConverter x:Key="MoneyConverter" />
    </UserControl.Resources>

    <controlsToolkit:BusyIndicator x:Name="Busy"
                                   HorizontalContentAlignment="Stretch"
                                   VerticalContentAlignment="Stretch">
        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid DataContext="{Binding Member, Mode=OneWay}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock HorizontalAlignment="Left"
                           FontSize="16"
                           Text="{Binding UserID, Converter={StaticResource UserIDConverter}, ConverterParameter='FullName', Mode=OneWay}" />
                <TextBlock HorizontalAlignment="Left"
                           Grid.Row="1"
                           Margin="6,2,0,2"
                           Text="{Binding ProjectID, Converter={StaticResource ProjectIDConverter}, ConverterParameter='Name', Mode=OneWay}" />
            </Grid>
            <Grid Grid.Row="1">
                <dataFormToolkit:DataForm x:Name="ProjectMemberDataForm"
                                          CurrentItem="{Binding Member, Mode=OneWay}"
                                          AutoCommit="False"
                                          AutoEdit="True"
                                          AutoGenerateFields="False"
                                          CommandButtonsVisibility="None">
                    <dataFormToolkit:DataForm.EditTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <dataFormToolkit:DataField>
                                    <TextBox Text="{Binding HourlyRate, Converter={StaticResource MoneyConverter}, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                </dataFormToolkit:DataField>
                                <dataFormToolkit:DataField>
                                    <controls:DatePicker SelectedDate="{Binding StartDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                </dataFormToolkit:DataField>
                                <dataFormToolkit:DataField>
                                    <controls:DatePicker SelectedDate="{Binding EndDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                </dataFormToolkit:DataField>
                            </StackPanel>
                        </DataTemplate>
                    </dataFormToolkit:DataForm.EditTemplate>
                </dataFormToolkit:DataForm>
            </Grid>

            <Grid Grid.Row="2">
                <Button Content="Close"
                        Margin="4"
                        Click="Close_Click" />
            </Grid>

        </Grid>
    </controlsToolkit:BusyIndicator>
</UserControl>